package com.digitalchina.lxnsy.activity.old;

import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;

import com.digitalchina.lxnsy.R;
import com.digitalchina.lxnsy.api.BusinessAccount;
import com.digitalchina.lxnsy.base.BaseActivity;
import com.digitalchina.lxnsy.constant.Constant;
import com.digitalchina.lxnsy.constant.URL;
import com.digitalchina.lxnsy.entity.FamousInterviewVO;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * ================================================
 * 项目名称：BigData
 * 类描述：
 * 包名：com.digitalchina.bigdata.activity
 * 创建人：郑皓
 * 创建时间：2017/7/31 15:40
 * 修改备注：
 * ================================================
 */
public class InterviewDetailActivity extends BaseActivity {

    @Bind(R.id.id_wv)
    WebView idWv;
    private FamousInterviewVO famousInterviewVO;

    private String id = "";

    @Override
    public void setLayout() {
        setContentLayout(R.layout.activity_interview_detail);
        setTitle("专访详情");
        setRightImage(R.drawable.ic_service_share);
    }

    @Override
    public void initMember() {
        //启用支持javascript
        WebSettings settings = idWv.getSettings();
        settings.setJavaScriptEnabled(true);

        if (getIntent().hasExtra("bannerId")) {
            mIvRight.setVisibility(View.INVISIBLE);
            id = getIntent().getSerializableExtra("bannerId").toString();
            // 浏览次数统计
            BusinessAccount.appBrowse(this, id, "6", "banner进入专访详情", splitUrl(id), mHandler);
        }else{
            famousInterviewVO = (FamousInterviewVO) getIntent().getSerializableExtra("FamousInterviewVO");
            id = famousInterviewVO.getId();
            // 浏览次数统计
            BusinessAccount.appBrowse(this, id, "6", famousInterviewVO.getTitle(), splitUrl(id), mHandler);
        }


        //优先使用缓存:
//        settings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
        idWv.loadUrl(splitUrl(id));
    }

    private String splitUrl(String id) {
        return URL.URL_GET_INTER_VIEW_DETAIL + id;
    }

    @Override
    public void addListener() {

    }

    @Override
    public void setHandler() {
        mHandler = new Handler() {
            @Override
            public void handleMessage(Message msg) {
                super.handleMessage(msg);
            }
        };
    }

    @Override
    public void callBack(Object object) {

    }

    @Override
    public void rightOnClick() {
          }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }
}
